package com.fr.data.core.db.handler;

import java.util.HashMap;
import java.util.Map;

public class SQLTypeHandlerFactory
{
  private Map handlerMap = new HashMap();
  private final SQLTypeHandler unknownTypeHandler = new UnknownTypeHandler();
  private static SQLTypeHandlerFactory sqlTypeHandlerFactory = new SQLTypeHandlerFactory();

  private SQLTypeHandlerFactory()
  {
    register(2003, new ArrayTypeHandler());
    register(-5, new LongTypeHandler());
    register(-2, new BlobTypeHandler());
    register(2004, new BlobTypeHandler());
    register(-7, new BooleanTypeHandler());
    register(16, new BooleanTypeHandler());
    register(1, new StringTypeHandler());
    register(2005, new ClobTypeHandler());
    register(70, new URLTypeHandler());
    register(91, new DateTypeHandler());
    register(3, new BigDecimalTypeHandler());
    register(8, new DoubleTypeHandler());
    register(2001, new ObjectTypeHandler());
    register(6, new FloatTypeHandler());
    register(4, new IntegerTypeHandler());
    register(2000, new ObjectTypeHandler());
    register(-4, new BlobTypeHandler());
    register(-1, new ClobTypeHandler());
    register(2, new BigDecimalTypeHandler());
    register(7, new FloatTypeHandler());
    register(2006, new RefTypeHandler());
    register(5, new ShortTypeHandler());
    register(2002, new ObjectTypeHandler());
    register(92, new TimeTypeHandler());
    register(93, new DBTimestampTypeHandler());
    register(-6, new ByteTypeHandler());
    register(-3, new BlobTypeHandler());
    register(12, new StringTypeHandler());
    register(1111, new ClobTypeHandler());
  }

  public static SQLTypeHandlerFactory buildSQLTypeHanderFactory()
  {
    return sqlTypeHandlerFactory;
  }

  public void register(int paramInt, SQLTypeHandler paramSQLTypeHandler)
  {
    this.handlerMap.put(new Integer(paramInt), paramSQLTypeHandler);
  }

  public SQLTypeHandler getTypeHandler(Integer paramInteger)
  {
    if (this.handlerMap.get(paramInteger) == null)
      return this.unknownTypeHandler;
    return ((SQLTypeHandler)this.handlerMap.get(paramInteger));
  }
}